import 'dart:math';

import 'package:flutter/material.dart';

class FaceRecognitionOverlay extends CustomPainter {

  final double radius;

  FaceRecognitionOverlay(this.radius);
  

  @override
  void paint(Canvas canvas, Size size) {
    final Paint paint = Paint()
      ..color = Colors.white
      ..style = PaintingStyle.fill;


    final double centerX = size.width / 2;
    final double centerY = size.height / 2;
    final minSize = min(centerY, centerX);
    final fRadius = min(minSize, radius);

    final Path path = Path()..addRect(Rect.fromLTWH(0, 0, size.width, size.height));
    path.addOval(Rect.fromCircle(center: Offset(centerX, centerY), radius: fRadius));
    path.fillType = PathFillType.evenOdd;

    canvas.drawPath(path, paint);
    // 绘制蓝色边框
    final Paint borderPaint = Paint()
      ..color = Colors.blue
      ..style = PaintingStyle.stroke
      ..strokeWidth = 2;

    canvas.drawCircle(Offset(centerX, centerY), fRadius, borderPaint);
  }

  @override
  bool shouldRepaint(FaceRecognitionOverlay oldDelegate) => false;
}